import { requestClient } from '#/api/request';

export namespace WorkflowApi {
  export interface DscModelInnerParams {
    category: string;
    toolId: string;
    name: string;
    identifier: string;
  }

  export interface DscModelParams {
    inputs: DscModelInnerParams[];
    outputs: DscModelInnerParams[];
    options: DscModelInnerParams[];
  }

  export interface WorkflowModel {
    id: string;
    name: string;
    category: string;
    description: string;
    params: DscModelParams;
    modelJson: string;
    author: string;
    ownerId: string;
    createTime: string;
    updateTime: string;
  }
}
const getDscWorkflowModel = (modelId: string) => {
  return requestClient.get(
    `/dsc-systemMS/dsc-workflow/getWorkflowModel/${modelId}`,
  );
};

const saveDscWorkflowModel = (
  workflowModel: WorkflowApi.WorkflowModel,
  userId: string,
) => {
  return requestClient.post(
    `/dsc-systemMS/dsc-workflow/saveWorkflowModel/${userId}`,
    workflowModel,
  );
};

const deleteDscWorkflowModel = (modelId: string) => {
  return requestClient.delete(
    `/dsc-systemMS/dsc-workflow/deleteWorkflowModel/${modelId}`,
  );
};

const updateDscWorkflowModel = (workflowModel: WorkflowApi.WorkflowModel) => {
  return requestClient.put(
    `/dsc-systemMS/dsc-workflow/updateWorkflowModel`,
    workflowModel,
  );
};

const getDscWorkflowModelList = (userId: string) => {
  return requestClient.get(
    `/dsc-systemMS/dsc-workflow/getWorkflowModelList/${userId}`,
  );
};

export default {
  getDscWorkflowModel,
  saveDscWorkflowModel,
  deleteDscWorkflowModel,
  updateDscWorkflowModel,
  getDscWorkflowModelList,
};
